1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module adw.SpringParams; 26 27 private import adw.c.functions; 28 public import adw.c.types; 29 private import glib.ConstructionException; 30 private import gobject.ObjectG; 31 private import linker.Loader; 32 33 34 /** 35 * Physical parameters of a spring for [class@SpringAnimation]. 36 * 37 * Any spring can be described by three parameters: mass, stiffness and damping. 38 * 39 * An undamped spring will produce an oscillatory motion which will go on 40 * forever. 41 * 42 * The frequency and amplitude of the oscillations will be determined by the 43 * stiffness (how "strong" the spring is) and its mass (how much "inertia" it 44 * has). 45 * 46 * If damping is larger than 0, the amplitude of that oscillating motion will 47 * exponientally decrease over time. If that damping is strong enough that the 48 * spring can't complete a full oscillation, it's called an overdamped spring. 49 * 50 * If we the spring can oscillate, it's called an underdamped spring. 51 * 52 * The value between these two behaviors is called critical damping; a 53 * critically damped spring will comes to rest in the minimum possible time 54 * without producing oscillations. 55 * 56 * The damping can be replaced by damping ratio, which produces the following 57 * springs: 58 * 59 * * 0: an undamped spring. 60 * * Between 0 and 1: an underdamped spring. 61 * * 1: a critically damped spring. 62 * * Larger than 1: an overdamped spring. 63 * 64 * As such 65 * 66 * Since: 1.0 67 */ 68 public class SpringParams 69 { 70 /** the main Gtk struct */ 71 protected AdwSpringParams* adwSpringParams; 72 protected bool ownedRef; 73 74 /** Get the main Gtk struct */ 75 public AdwSpringParams* getSpringParamsStruct(bool transferOwnership = false) 76 { 77 if (transferOwnership) 78 ownedRef = false; 79 return adwSpringParams; 80 } 81 82 /** the main Gtk struct as a void* */ 83 protected void* getStruct() 84 { 85 return cast(void*)adwSpringParams; 86 } 87 88 /** 89 * Sets our main struct and passes it to the parent class. 90 */ 91 public this (AdwSpringParams* adwSpringParams, bool ownedRef = false) 92 { 93 this.adwSpringParams = adwSpringParams; 94 this.ownedRef = ownedRef; 95 } 96 97 ~this () 98 { 99 if ( Linker.isLoaded(LIBRARY_ADW[0]) && ownedRef ) 100 adw_spring_params_unref(adwSpringParams); 101 } 102 103 104 /** */ 105 public static GType getType() 106 { 107 return adw_spring_params_get_type(); 108 } 109 110 /** 111 * Creates a new `AdwSpringParams` from @mass, @stiffness and @damping_ratio. 112 * 113 * The damping value is calculated from @damping_ratio and the other two 114 * parameters. 115 * 116 * * If @damping_ratio is 0, the spring will not be damped and will oscillate 117 * endlessly. 118 * * If @damping_ratio is between 0 and 1, the spring is underdamped and will 119 * always overshoot. 120 * * If @damping_ratio is 1, the spring is critically damped and will reach its 121 * resting position the quickest way possible. 122 * * If @damping_ratio is larger than 1, the spring is overdamped and will reach 123 * its resting position faster than it can complete an oscillation. 124 * 125 * [ctor@SpringParams.new_full] allows to pass a raw damping value instead. 126 * 127 * Params: 128 * dampingRatio = the damping ratio of the spring 129 * mass = the mass of the spring 130 * stiffness = the stiffness of the spring 131 * 132 * Returns: the newly created spring parameters 133 * 134 * Since: 1.0 135 * 136 * Throws: ConstructionException GTK+ fails to create the object. 137 */ 138 public this(double dampingRatio, double mass, double stiffness) 139 { 140 auto __p = adw_spring_params_new(dampingRatio, mass, stiffness); 141 142 if(__p is null) 143 { 144 throw new ConstructionException("null returned by new"); 145 } 146 147 this(cast(AdwSpringParams*) __p); 148 } 149 150 /** 151 * Gets the damping of @self. 152 * 153 * Returns: the damping 154 * 155 * Since: 1.0 156 */ 157 public double getDamping() 158 { 159 return adw_spring_params_get_damping(adwSpringParams); 160 } 161 162 /** 163 * Gets the damping ratio of @self. 164 * 165 * Returns: the damping ratio 166 * 167 * Since: 1.0 168 */ 169 public double getDampingRatio() 170 { 171 return adw_spring_params_get_damping_ratio(adwSpringParams); 172 } 173 174 /** 175 * Gets the mass of @self. 176 * 177 * Returns: the mass 178 * 179 * Since: 1.0 180 */ 181 public double getMass() 182 { 183 return adw_spring_params_get_mass(adwSpringParams); 184 } 185 186 /** 187 * Gets the stiffness of @self. 188 * 189 * Returns: the stiffness 190 * 191 * Since: 1.0 192 */ 193 public double getStiffness() 194 { 195 return adw_spring_params_get_stiffness(adwSpringParams); 196 } 197 198 alias doref = ref_; 199 /** 200 * Increases the reference count of @self. 201 * 202 * Returns: @self 203 * 204 * Since: 1.0 205 */ 206 public SpringParams ref_() 207 { 208 auto __p = adw_spring_params_ref(adwSpringParams); 209 210 if(__p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(SpringParams)(cast(AdwSpringParams*) __p, true); 216 } 217 218 /** 219 * Decreases the reference count of @self. 220 * 221 * If the last reference is dropped, the structure is freed. 222 * 223 * Since: 1.0 224 */ 225 public void unref() 226 { 227 adw_spring_params_unref(adwSpringParams); 228 } 229 }